package com.cn.order.tcc;

import io.seata.rm.tcc.api.BusinessActionContext;
import io.seata.rm.tcc.api.BusinessActionContextParameter;
import io.seata.rm.tcc.api.LocalTCC;
import io.seata.rm.tcc.api.TwoPhaseBusinessAction;

import java.math.BigDecimal;

@LocalTCC
public interface OrderTCCAction {
    @TwoPhaseBusinessAction(name = "OrderTCCAction",commitMethod = "commit",rollbackMethod = "rollback")
    boolean prepare(
//            tcc上下文对象，通过ctx对象，在两个阶段传递业务数据
//            业务对象放置上下文对象中
            BusinessActionContext ctx,
//            通过上下文对象可以将数据传递到第二阶段
            @BusinessActionContextParameter(paramName = "id") Long id,
            @BusinessActionContextParameter(paramName = "userId") Long userId,
            @BusinessActionContextParameter(paramName = "productId") Long productId,
            @BusinessActionContextParameter(paramName = "count") Integer count,
            @BusinessActionContextParameter(paramName = "money") BigDecimal money,
            @BusinessActionContextParameter(paramName = "status") Integer status
    );
//    commit方法
    boolean commit(BusinessActionContext context);
//    rollback方法
    boolean rollback(BusinessActionContext context);
}
